A call branch instruction allows program control to branch to a section of code that implements a subroutine (function). For example, when a call branch instruction executes, the address in the program counter is incremented and loaded into a link register to be recalled later, and the address of the first line of code in the called subroutine is loaded into the program counter so that program control branches to the section of code representing the called subroutine. A return branch instruction at the end of the section of code causes program control to return to the address stored in the link register, thereby returning to the instruction next in program order after the call branch instruction that called the subroutine.
To implement nested or recursive subroutines (functions), that is, where a subroutine calls another subroutine (which may be itself), software may utilize a stack in memory. For example, if an address has been loaded into the link register due to a first subroutine call, and if a second subroutine is called within the code representing the first subroutine, then the address that was loaded into the link register when the first subroutine was called is pushed onto the top of the stack in memory by software convention, and an address representing the next instruction in program order after the second branch instruction is loaded into the link register. When a return branch instruction for the second called subroutine is executed, the address stored in the link register is loaded into the program counter, and the address at the top of the stack is then popped off and loaded into the link register so that program control may return to the instruction immediately following (in program order) the first branch instruction when the first subroutine completes.